<html>
    <head>
        <title>Eliminar Zonas</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <?php echo link_tag('bootstrap/css/estilo.css') ?>
        <?php echo link_tag('bootstrap/css/bootstrap.min.css') ?>
        <?php echo link_tag('bootstrap/css/layout.css') ?> 
        <?php echo link_tag('bootstrap/css/tablascss.css') ?>
    </head>
    <body>
        <fieldset>
            <div class="body" id="container">
                <section id="buttonGroups">
                    <div class="page-header">
                        <h1>Modificar Zonas SIMERT</h1>
                    </div>
                    <div class="row">
                        <div class="span8">
                            <?php if (!isset($modificar) && $var == FALSE) { ?>
                                <div class="datagrid" style="margin-right: -80px; margin-left: -20px; overflow-y: auto;  height: <?php if(count($contenido)<6){ echo 'auto';}else{echo '300px';}?>" >
                                    <table class="table" border="2" style=" overflow-y: scroll" id="paginador"> 
                                        <tr >
                                            <td bgcolor="#CCCOCC"><center><b>ID</b></center></td>
                                            <td  bgcolor="#CCCOCC" width="60px" ><center><b>ZONA</b></center></td>
                                            <td  bgcolor="#CCCOCC" width="100px" ><center><b>PRINCIPAL</b></center></td>
                                            <td  bgcolor="#CCCOCC" width="105px" ><center><b>SECUNDARIA 1</b></center></td>
                                            <td  bgcolor="#CCCOCC" width="105px" ><center><b>SECUNDARIA 2</b></center></td>
                                            <td  bgcolor="#CCCOCC"><center><b>ORIENTACIÓN</b></center></td>        
                                            <td  bgcolor="#CCCOCC"><center><b>ESPACIOS</b></center></td>
                                            <td  bgcolor="#CCCOCC"><center><b>HABILITADO</b></center></td>
                                            <td  bgcolor="#CCCOCC"><center><b>MODIFICAR</center></td>
                                        </tr>
                                        <?php for ($i = 0; $i < count($contenido); $i++) { ?>
                                            <tr>
                                                <td><center><?php echo $i + 1; ?></center></td>
                                                <td><center><?php echo $contenido[$i]['zona']; ?></center></td>
                                                <td><center><?php echo $contenido[$i]['principal']; ?></center></td>
                                                <td><center><?php echo $contenido[$i]['sec1']; ?></center></td>
                                                <td><center><?php echo $contenido[$i]['sec2']; ?></center></td>
                                                <td><center><?php echo $contenido[$i]['orientacion']; ?></center></td>
                                                <td><center><?php echo $contenido[$i]['amarillos'] + $contenido[$i]['azules']; ?></center></td>
                                                <td><center><?php if($contenido[$i]['uso']==1){echo 'SI';}else{echo 'NO';} ?></center></td>
                                                <td><center> <form method="POST" action="/simertweb/eliminar_zona/cargar_subcalle"><button name="modificar" value="<?php echo $contenido[$i]['id']; ?>">MODIFICAR</button></form> </center></td> 
                                            </tr>
                                        <?php } ?> 
                                    </table>
                                </div>
                                <form method="POST" target="_blank" action="/simertweb/eliminar_zona/generar_pdf">
                                    <br>
                                    <button type="submit" class="btn btn-primary">Imprimir</button>
                                </form>
                                <?php
                            } else {
                                ?>
                                <form class="form-horizontal" method="POST" action="/simertweb/eliminar_zona/modificar">
                                    <?php
                                    foreach ($listacalles as $key) {
                                        if (!empty($key->nombreZona)) {
                                            $listaZonas[] = $key;
                                        }
                                    }
                                    foreach ($listacalles as $key) {
                                        if (!empty($key->nombre)) {
                                            $listaC[] = $key;
                                        }
                                    }
                                    ?>
                                    <a href="https://maps.google.com.ec/" target="_blank"> <u><font size="3" color="navy">Ir a Google Maps</font></u></a>  
                                    <br><br><br>
                                    <div class="invisible">
                                        <?php echo form_error('idSubcalle'); ?>
                                        <label class="control-label"><b>Subcalle:</b></label>
                                        <input name="idSubcalle" value="<?php
                                    if (isset($modificar) == FALSE) {
                                        echo set_value('idSubcalle');
                                    } else {
                                        echo $modificar['idsubcalle'];
                                    }
                                        ?>">

                                    </div> 

                                    <div class="control-group">
                                        <div class="controls">
                                            <?php echo form_error('zona'); ?>

                                            <label class="control-label"><b>Zona:</b></label>
                                            <select class="span3"  name="zona" >
                                                <?php foreach ($listaZonas as $fila) { ?>
                                                    <option <?php
                                            if (isset($modificar)) {
                                                if ($fila->nombreZona == $modificar['zona']) {
                                                    echo 'selected';
                                                }
                                            } else {
                                                if ($fila->nombreZona == set_value('zona')) {
                                                    echo 'selected';
                                                }
                                            }
                                                    ?>> <?php echo $fila->nombreZona; ?> </option>  
                                                    <?php } ?> 
                                            </select> 
                                            <b class="warning" style="font-size: 20px">&nbsp;&nbsp;</b>
                                        </div>  
                                    </div>

                                    <div class="control-group">
                                        <div class="controls">
                                            <?php echo form_error('calle'); ?>
                                            <label class="control-label" ><b>Principal:</b></label>
                                            <select class="span3"  name="calle" >
                                                <?php foreach ($listaC as $fila) { ?>
                                                    <option <?php
                                            if (isset($modificar)) {
                                                if ($fila->nombre == $modificar['principal']) {
                                                    echo 'selected';
                                                }
                                            } else {
                                                if ($fila->nombre == set_value('calle')) {
                                                    echo 'selected';
                                                }
                                            }
                                                    ?>><?php echo $fila->nombre; ?> </option>
                                                    <?php } ?> 
                                            </select>
                                            <b class="warning" style="font-size: 20px">&nbsp;&nbsp;</b>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <div class="controls">
                                            <label class="control-label" ><b>Entre:</b></label>
                                            <select class="span3" name="sec_1" >
                                                <?php foreach ($listaC as $fila) { ?>
                                                    <option <?php
                                            if (isset($modificar)) {
                                                if ($fila->nombre == $modificar['sec1']) {
                                                    echo 'selected';
                                                }
                                            } else {
                                                if ($fila->nombre == set_value('sec_1')) {
                                                    echo 'selected';
                                                }
                                            }
                                                    ?>><?php echo $fila->nombre; ?> </option>
                                                    <?php } ?> 
                                            </select>
                                            <b class="warning" style="font-size: 20px">&nbsp;&nbsp;</b>
                                        </div>  
                                    </div>

                                    <div class="control-group">
                                        <div class="controls">
                                            <?php echo form_error('lon_1'); ?>
                                            <label class="control-label" >Punto 1:</label>
                                            <input type="text" class="medium" id="nombre"  name="lon_1" value="<?php
                                        if (isset($modificar)) {
                                            echo $modificar['X1'];
                                        } else {
                                            echo set_value('lon_1');
                                        }
                                            ?>">
                                            <b class="warning" style="font-size: 20px">&nbsp;*</b>
                                            <br>
                                            <?php echo form_error('lat_1'); ?>
                                            <label class="control-label" for="nombre">Punto 2:</label>
                                            <input type="text" class="medium" id="nombre"  name="lat_1" value="<?php
                                        if (isset($modificar)) {
                                            echo $modificar['Y1'];
                                        } else {
                                            echo set_value('lat_1');
                                        }
                                            ?>">
                                            <b class="warning" style="font-size: 20px">&nbsp;*</b>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <div class="controls">
                                            <label class="control-label" for="nombre"><b>y</b>:</label>
                                            <select class="span3"  name="sec_2">
                                                <?php foreach ($listaC as $fila) { ?>
                                                    <option <?php
                                            if (isset($modificar)) {
                                                if ($fila->nombre == $modificar['sec2']) {
                                                    echo 'selected';
                                                }
                                            } else {
                                                if ($fila->nombre == set_value('sec_2')) {
                                                    echo 'selected';
                                                }
                                            }
                                                    ?>><?php echo $fila->nombre; ?> </option>
                                                    <?php } ?> 
                                            </select> 
                                            <b class="warning" style="font-size: 20px">&nbsp;&nbsp;</b>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <div class="controls">
                                            <?php echo form_error('lon_2'); ?>
                                            <label class="control-label" for="nombre">Punto 3:</label>
                                            <input type="text" class="medium" id="nombre"  name="lon_2"  value="<?php
                                        if (isset($modificar)) {
                                            echo $modificar['X2'];
                                        } else {
                                            echo set_value('lon_2');
                                        }
                                            ?>">
                                            <b class="warning" style="font-size: 20px">&nbsp;*</b>
                                            <br>
                                            <?php echo form_error('lat_2'); ?>
                                            <label class="control-label" for="nombre">Punto 4:</label>
                                            <input type="text" class="medium" id="nombre" name="lat_2"  value="<?php
                                        if (isset($modificar)) {
                                            echo $modificar['Y2'];
                                        } else {
                                            echo set_value('lat_2');
                                        }
                                            ?>">
                                            <b class="warning" style="font-size: 20px">&nbsp;*</b>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <div class="controls">
                                            <?php echo form_error('orientacion'); ?>
                                            <label class="control-label"><b>Orientación:</b></label>
                                            <select class="span3" class="medium"  name="orientacion">

                                                <?php if (isset($modificar)) { ?>
                                                    <option <?php
                                            if ($modificar['orientacion'] == 'Norte') {
                                                echo 'selected';
                                            }
                                                    ?> >Norte</option>
                                                    <option <?php
                                                if ($modificar['orientacion'] == 'Sur') {
                                                    echo 'selected';
                                                }
                                                    ?>>Sur</option>
                                                    <option <?php
                                                if ($modificar['orientacion'] == 'Este') {
                                                    echo 'selected';
                                                }
                                                    ?>>Este</option>
                                                    <option <?php
                                                if ($modificar['orientacion'] == 'Oeste') {
                                                    echo 'selected';
                                                }
                                                    ?>>Oeste</option>
                                                    <?php } else { ?>
                                                    <option <?php
                                                if (set_value('orientacion') == 'Norte') {
                                                    echo 'selected';
                                                }
                                                        ?> >Norte</option>
                                                    <option <?php
                                                if (set_value('orientacion') == 'Sur') {
                                                    echo 'selected';
                                                }
                                                        ?>>Sur</option>
                                                    <option <?php
                                                if (set_value('orientacion') == 'Este') {
                                                    echo 'selected';
                                                }
                                                        ?>>Este</option>
                                                    <option <?php
                                                if (set_value('orientacion') == 'Oeste') {
                                                    echo 'selected';
                                                }
                                                        ?>>Oeste</option>    
                                                    <?php } ?>
                                            </select>
                                            <b class="warning" style="font-size: 20px">&nbsp;&nbsp;</b>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <div class="controls">
                                            <?php echo form_error('azules'); ?>
                                            <label class="control-label" ><b>Espacios SIMERT:</b></label>
                                            <input type="text" class="input-mini"  name="azules" style="margin-left: -145px" value="<?php
                                            if (isset($modificar)) {
                                                echo $modificar['espacios'];
                                            } else {
                                                echo set_value('azules');
                                            }
                                            ?>">
                                            <b class="warning" style="font-size: 20px">&nbsp;*</b>

                                            <!--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
        <!--                                    <input type="text" class="input-xlarge" id="azules" name="amarillos" style="width: 20px; " >
                                            amarillos &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <div class="controls">
                                            <label class="control-label">Habilitado:</label>

                                            <input type="checkbox" name="habilitado" style= "margin-left: -220px"  value="<?php
                                        if (isset($modificar)) {
                                            echo $modificar['habilitado'];
                                        }
                                            ?>"
                                                   <?php  if (isset($modificar)) {if ($modificar['habilitado'] == 1) { ?>
                                                       checked="checked">
                                                   <?php } }?>
                                        </div>
                                    </div>
                                    <button type="submit" class="btn btn-primary">Guardar Cambios</button>  
                                </form>
                            <?php } ?>
                        </div>
                    </div>
                </section>     
            </div>
        </fieldset>
    </body>
</html>

